# coding: utf-8
# author: t_wolf


from framework import *


class Base(object):
    header = None            # 请求头
    session = None           # 用户会话
    request = None           # 请求参数
    pattern = None           # 请求url中的正则匹配项
    filter_list = []         # 全局过滤器

    pages = None             # 页面渲染对象

    frame_worker = False     # 框架类标识
    url_origin = None        # 源监听Url

    @override
    def post(self): pass

    @override
    def get(self): pass

    @override
    def put(self): pass

    @override
    def delete(self): pass

    def session_get(self, key):
        return self.session[key] if self.session_has(key) else None

    def session_dump(self):
        return self.session.items()

    def session_has(self, key):
        return True if key in self.session else False

    def session_put(self, key, value):
        self.session.setdefault(key, value)

    def header_get(self, key):
        return self.header[key] if self.header_has(key) else None

    def header_dump(self):
        return self.header.items()

    def header_has(self, key):
        return True if key in self.header else False

    def header_put(self, key, value):
        return web.header(key, value)

    def request_get(self, key):
        return self.request[key] if self.request_has(key) else None

    def request_dump(self):
        return self.request.items()

    def request_has(self, key):
        return True if key in self.request else False
